package com.pinyougou.user.controller;

import com.pinyougou.pojo.TbUser;
import com.pinyougou.user.service.UserDetailServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/login")
public class LoginController {

    @RequestMapping("/name")
    public Map getLoginUser() {

        String name = SecurityContextHolder.getContext().getAuthentication().getName();

        Map<String, String> map = new HashMap<>();

        map.put("loginName",name);

        return map;

    }

}
